import { apiShopMange } from 'js/api'

export default {
  state: {
    storeList: [],
    par: {
      accessToken: '',
      threeMenuCode: '',
      currentPage: 1,
      showCount: 999
    }
  },
  getters: {
    storeList: state => state.storeList
  },
  actions: {
    /**
     * 获取 店铺 列表
     */
    fetchStoreList({ state }, params) {
      state.par.accessToken = params.token
      state.par.threeMenuCode = params.three

      apiShopMange.apiShopList(state.par).then(data => {
        const list = data.data.recordList || []
        state.storeList = list.map(item => {
          return {
            value: item.id,
            label: item.licenseCname
          }
        })
      })
    }
  }
}